<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>老师订单</cite></a>
              <a><cite>老师试课</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>
                            预约号
                        </th>
                        <th>
                            家长
                        </th>
                        <th>
                            性别
                        </th>
                        <th>
                            手机
                        </th>
                        <th>
                            科目
                        </th>
                        <th>
                            试听时间
                        </th>
                        <th>
                            试听地点
                        </th>
                        <th>
                            状态
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($yuyues as $u) { ?>
                    <tr>
                        <td>
                            {$u.id}
                        </td>
                        <td>
                            <u style="cursor:pointer" onclick="member_show('张三','member-show.html','10001','360','400')">
                                {$u.name}
                            </u>
                        </td>
                        <td >
                            {$u.sex}
                        </td>
                        <td >
                            {$u.phone}
                        </td>
                        <th>
                            {$u.subject}
                        </th>
                        <th>
                            {$u.date} {$u.time}
                        </th>
                        <th>
                            {$u.city_quyu}
                        </th>
                        <td class="td-status">
                            <?php if ($u['is_laoshi_on']==1) { ?>
                                <span class="layui-btn layui-btn-disabled layui-btn-mini">接受</span>
                            <?php }else { ?>
                                <span class="layui-btn layui-btn-disabled layui-btn-mini">未接受</span>
                            <?php } ?>
                        </td>
                        <td class="td-manage">
                            <?php if ($u['is_laoshi_on']==1) { ?>
                                <a title="取消" href="javascript:;" onclick="member_del(this,{$u['id']})" style="text-decoration:none"><span class="layui-btn layui-btn-mini">取消</span></a>
                            <?php }else { ?>
                                <a class="td-stop" style="text-decoration:none" onclick="member_start(this,{$u['id']})" href="javascript:;" title="接受">
                                <span class="layui-btn layui-btn-mini">接受</span></a> 
                            <?php } ?>
                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
            <style>
                .fenye{ margin-top: 20px;}
                .fenye div a,.fenye div span{display: inline-block;padding: 5px 15px;margin-right: -1px;border: 1px solid #1AA094;}
                .fenye div span{background: #1AA094;color: #fff;}
            </style>
            <div class="fenye">{$page}</div>
        </div>
        <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="__PUBLIC__/admin/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层

              //以上模块根据需要引入
              
            });

            /*老师-接受*/
            function member_start(obj,id){
                layer.confirm('确认要接受吗？',function(index){
                    //发异步把用户状态进行更改
                    id = id;
                    $.ajax({
                        url: "{:U('admin/order/jieshou_on')}",//请求地址
                        type: "post",//请求方式
                        dataType: "json",//返回数据类型
                        data: {id:id},//发送的参数
                        })
                        .done(function(response) {
                              if(response.error==1){
                                layer.msg(response.info ,{icon:6});
                                location.reload();
                              }else{
                                layer.msg(response.info ,{icon:5});
                              }
                          })
                        .fail(function() {
                            alert("ajxs交互失败");
                        })  
                    return false;
                });
            }

            /*老师试课取消-删除*/
            function member_del(obj,id){
                layer.confirm('确认要取消吗？',function(index){
                    //发异步删除数据
                    id = id;
                    $.ajax({
                        url: "{:U('admin/order/quxiao_off')}",//请求地址
                        type: "post",//请求方式
                        dataType: "json",//返回数据类型
                        data: {id:id},//发送的参数
                        })
                        .done(function(response) {
                              if(response.error==1){
                                layer.msg(response.info ,{icon:6});
                                $(obj).parents("tr").remove();
                              }else{
                                layer.msg(response.info ,{icon:5});
                              }
                          })
                        .fail(function() {
                            alert("ajxs交互失败");
                        })  
                    return false;
                });
            }
            </script>
    </body>
</html>